package com.xin.springcloudconsumer.feign;

import com.xin.springcloudconsumer.dto.PageResult;
import com.xin.springcloudconsumer.dto.UserDTO;
import com.xin.springcloudconsumer.form.UserForm;
import com.xin.springcloudconsumer.vo.ResultPage;
import com.xin.springcloudconsumer.vo.ResultVO;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.*;


@FeignClient("springcloud-user")
@RequestMapping("/user")
public interface UserFeign {
    /**
     * 创建用户
     *
     * @param userForm
     * @return
     */
    @PostMapping("/create")
    public ResultVO create(@RequestBody(required = false) UserForm userForm);

    /**
     * 修改用户信息
     *
     * @param userForm
     * @return
     */
    @PostMapping("/update")
    public ResultVO update(@RequestBody(required = false) UserForm userForm);

    /**
     * 删除用户
     *
     * @param id
     * @return
     */
    @GetMapping("/delete")
    public ResultVO delete(@RequestParam(name = "id", defaultValue = "") String id) ;


    /**
     * 查询用户（id）
     *
     * @param id
     * @return
     */
    @GetMapping("/findOne")
    public ResultVO findOne(@RequestParam(name = "id", defaultValue = "") String id);

    /**
     *模糊查询（nickname）
     * @param nickname
     * @param
     * @return
     */
    @GetMapping("/findAllByLikeName")
    public ResultPage<UserDTO> findAllByLikeName(@RequestParam(value = "nickname", defaultValue = "") String nickname,
                                                 @RequestParam(name = "page",defaultValue = "")Integer page,
                                                 @RequestParam(name="size",defaultValue = "")Integer size);

    /**
     * 查询用户(手机号)
     * @param phone
     * @return
     */
    @GetMapping("/findOneByPhone")
    public ResultVO findOneByPhone(@RequestParam(name = "phone",defaultValue = "")String phone);

    /**
     * 登录(正常登录)
     * @param phone
     * @param password
     * @return
     */
    @PostMapping("/login")
    public ResultVO login(@RequestParam(name = "phone",defaultValue = "")String phone,
                          @RequestParam(name = "password",defaultValue = "")String password);



}
